<?php

class Collection{
	private $_members=array(); //container for our objects
	
	public function addItem($obj,$key){
		if($key){
			//echo($key);
			if(isset($this->_members[$key])){
				throw new Exception($this->_members);
			}else{
				$this->_members[$key]=$obj;
			}
		}else{
			$this->_members[]=$obj;
		}
	}

	public function getItem($key){
		if(isset($this->_members[$key])){
			return $this->_members[$key];
		}else{
			throw new Exception("Sorry but the existing Key Doesn't not exist keys::".$this->_members);
		}
	}

	public  function removeItem($key){
		if(isset($this->_members[$key])){
			unset($this->_members[$key]);
		}else{
			throw new Exception("Sorry but the existing Key Doesn't not exist keys::".$this->_members);
		}
	}

	public function length(){
		return sizeof($this->_members);
	}

}


?>